﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LanguagePolish.Controls.WeekCalendar
{
    public class WeekCalendarModel
    {
        /// <summary>
        /// Дата для которой будет выводится недельный календарь.
        /// </summary>
        public DateTime CurrentDate { get; set; }

        /// <summary>
        /// Первый день текущей недели.
        /// </summary>
        public DateTime FirstDay 
        {
            get 
            {
                int day = CurrentDate.DayOfWeek.ToInt();
                return CurrentDate.AddDays(-day);
            }
        }

        /// <summary>
        /// Последний день текущей недели.
        /// </summary>
        public DateTime LastDay
        {
            get
            {
                int day = CurrentDate.DayOfWeek.ToInt();
                return CurrentDate.AddDays(6 - day);
            }
        }

        /// <summary>
        /// Инициализирует новый экземпляр <see cref="CalendarModel"/> для текущей даты.
        /// </summary>
        public WeekCalendarModel()
        { 
            DateTime now = DateTime.Now;
            CurrentDate = now;
        }

        public void IncrementWeek()
        {
            CurrentDate = CurrentDate.AddDays(7);
        }

        public void DecrementWeek()
        {
            CurrentDate = CurrentDate.AddDays(-7);
        }

    }
}
